package edu.scau.misp.backend_module.service.impl;

import edu.scau.misp.backend_module.domain.Dish;
import edu.scau.misp.backend_module.mapper.DishMapper;
import edu.scau.misp.backend_module.service.IDishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class DishServiceImpl implements IDishService {

    @Autowired
    private DishMapper dishMapper;































    //    ---------------------------------------以下是基础CRUD------------------------------------------

    /**
     * 根据编号Sn查询Dish餐品对象
     *
     * @param dishSn 餐品编号
     * @return 返回一个餐品Dish对象
     */
    @Override
    public Dish getDishBySn(Long dishSn) {
        return dishMapper.getDishBySn(dishSn);
    }

    /**
     * 根据ID查询Dish餐品对象(不常用)
     *
     * @param dishId 餐品ID
     * @return 返回一个餐品Dish对象
     */
    @Override
    public Dish getDishById(Long dishId) {
        return dishMapper.getDishById(dishId);
    }

    /**
     * 查询所有Dish餐品对象
     *
     * @return 返回一个泛型为Dish的集合
     */
    @Override
    public List<Dish> listAllDish() {
        return dishMapper.listAllDish();
    }

    /**
     * 根据Dish对象的名称进行模糊查询
     *
     * @param dish Dish餐品对象
     * @return 相关的泛型为Dish的集合
     */
    @Override
    public List<Dish> selectDishList(Dish dish) {
        return dishMapper.selectDishList(dish);
    }

    /**
     * 增加新的Dish餐品
     *
     * @param dish
     * @return
     */
    @Override
    public int insertDish(Dish dish) {
        return dishMapper.insertDish(dish);
    }

    /**
     * 修改Dish餐品
     *
     * @param dish
     * @return
     */
    @Override
    public int updateDish(Dish dish) {
        return dishMapper.updateDish(dish);
    }

    /**
     * 删除Dish餐品
     *
     * @param dishSn
     * @return
     */
    @Override
    public int deleteDishBySn(Long dishSn) {
        return dishMapper.deleteDishBySn(dishSn);
    }
}
